# tests/analyze_sample.py
import sys
import os

# 获取项目根目录（假设 src 和 tests 是同级目录）
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(project_root)

# 现在可以正常导入 src/ 下的模块
from src.data_reader import get_sample_comments
from src.data_analysis.analysis_comment import CommentAnalyzer
from src.utils.config_loader import Config
from src.models.database import DatabaseManager
import json

config = Config()
analyzer = CommentAnalyzer(api_key=config.DEEPSEEK_API_KEY)

# 1. 读取样本评论
sample_comments = get_sample_comments(limit=5)

# 2. 批量分析
results = analyzer.batch_analyze(sample_comments)

# 3. 输出结果
print(json.dumps(results, ensure_ascii=False, indent=2))